package com.gengral.bussiness.sys.user.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.gengral.bussiness.sys.user.entity.User;
import com.gengral.bussiness.sys.user.mapper.UserMapper;
import com.gengral.bussiness.sys.user.service.UserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author sht
 * @since 2020-04-14
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Autowired
    private UserMapper userMapper;

    /**
	* 根据id查询User
	*/
    @Override
    public User getUserById(Long id) throws Exception {
        return userMapper.getUserById(id);
    }

    /**
	* 查询User列表
	*/
    @Override
    public List<User> listUser(User user) throws Exception {
        return userMapper.listUser(user);
    }

    /**
	* 分页查询User列表
	*/
    @Override
	public Page<User> pageUser(User user, Integer pageNo, Integer pageSize) throws Exception {
        PageHelper.startPage(pageNo,pageSize);
        return userMapper.pageUser(user);
    }

    /**
	* 新增User
	*/
    @Override
    @Transactional
    public Integer addUser(User user) throws Exception {
        return userMapper.addUser(user);
    }

    /**
	* 更新User
	*/
    @Override
    @Transactional
    public Integer updateUser(User user) throws Exception {
        return userMapper.updateUser(user);
    }

   	/**
	* 根据id删除User
	*/
    @Override
    @Transactional
	public Integer deleteUserById(Long id) throws Exception {
        return userMapper.deleteUserById(id);
    }

	/**
	* 根据id逻辑删除User
	*/
    @Override
    @Transactional
	public Integer removeUserById(Long id) throws Exception {
        return userMapper.removeUserById(id);
    }
}
